import axios from 'axios'
import jsonp from 'common/js/jsonp'
import { commonParams, options } from './config'

export function getSingerList() {
    const url = 'https://c.y.qq.com/v8/fcg-bin/v8.fcg'

    const data = Object.assign({}, commonParams, {
        channel: 'singer',
        page: 'list',
        key: 'all_all_all',
        pagesize: 100,
        pagenum: 1,
        hostUin: 0,
        needNewCode: 0,
        platform: 'yqq',
        g_tk: 1664029744
    })

    return jsonp(url, data, options)
}

export function getSingerDetail(singerId) {
    const url = 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_singer_track_cp.fcg'

    const data = Object.assign({}, commonParams, {
        hostUin: 0,
        needNewCode: 0,
        platform: 'yqq',
        order: 'listen',
        singermid: singerId,
        songstatus: 1,
        begin: 0,
        num: 30,
        g_tk: 1664029744
    })

    return jsonp(url, data, options)
}

// 获取音乐播放源
// export function getMusic() {
//     const url = '/api/music'
//     const data = Object.assign({}, {
//         _: 1624779953671,
//         sign: 'zzamznxztegs24d3207b21e32ada6d12f70917a841e2e'
//     })

//     return axios.get(url, {
//         params: data
//     }).then((res) => {
//         return Promise.resolve(res, data)
//     })
// }

// 获取歌词vkey方法
export function getSongVkey(songmid) {
    const url = 'https://c.y.qq.com/base/fcgi-bin/fcg_music_express_mobile3.fcg'
    
    const data = Object.assign({}, {
    //   songmid: songmid,
    //   filename: `C400${songmid}.m4a`,
    //   guid: 7981028948,
    //   platform: 'yqq',
    //   loginUin: 0,
    //   hostUin: 0,
    //   needNewCode: 0,
    //   cid: 205361747,
    //   uid: 0,
    //   g_tk: 1928111839
        callback: 'musicJsonCallback',
        loginUin: 3051522991,
        format: 'jsonp',
        platform: 'yqq',
        needNewCode: 0,
        cid: 205361747,
        uin: 3051522991,
        guid: 5931742855,
        songmid: songmid,
        filename: `C400${songmid}.m4a`
    })
    return jsonp(url, data)
}
